package com.scsj.supermarket.view.activity.ordermodel;

import android.content.res.Resources;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;

import com.gigamole.navigationtabstrip.NavigationTabStrip;
import com.scsj.supermarket.R;
import com.scsj.supermarket.adapter.MainFragmentAdapter;
import com.scsj.supermarket.view.activity.baseactivitymodel.BaseActivity;
import com.scsj.supermarket.view.fragment.basemodel.BaseFragment;
import com.scsj.supermarket.view.fragment.myordermodel.TotalOrderFragment;

import java.lang.reflect.Field;
import java.util.ArrayList;

/**
 * 我的订单
 */
public class MyOrderActivity extends BaseActivity {

    private NavigationTabStrip mTopNavigationTabStrip;
    private ViewPager mViewPager;
    private ArrayList<BaseFragment> fragmentList;
    private MainFragmentAdapter mAdpter;
    private int orderStateNumber;
    private String[] title = {"全部", "待付款", "待发货", "待收货", "已完成"};

    private View mainView;

    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_my_order);
        orderStateNumber = getIntent().getIntExtra("order_state", -1);
        initToolbar();
        setToolbarTitle("我的订单");
        hasBack(true);

        initView();
        initListener();
        initData();
    }

    @Override
    protected void initView() {
        mainView = (View) findViewById(R.id.main_ly);
        intiNavigationBar();
    }

    @Override
    protected void initListener() {
    }

    @Override
    protected void initData() {
    }
    private void intiNavigationBar() {

        mTopNavigationTabStrip = findViewById(R.id.mediator_tab);
        mViewPager = findViewById(R.id.viewpager);
        mViewPager.setOffscreenPageLimit(4);
        fragmentList = new ArrayList<>();
        for (int i = 0; i < title.length; i++) {
            fragmentList.add(new TotalOrderFragment(i));
        }
        mAdpter = new MainFragmentAdapter(getSupportFragmentManager(), fragmentList);
        mViewPager.setAdapter(mAdpter);
        mViewPager.setCurrentItem(orderStateNumber);
        mTopNavigationTabStrip.setViewPager(mViewPager, orderStateNumber);
        mTopNavigationTabStrip.setTitles(title);
        mTopNavigationTabStrip.setStripType(NavigationTabStrip.StripType.LINE);
        mTopNavigationTabStrip.setStripGravity(NavigationTabStrip.StripGravity.BOTTOM);
        mTopNavigationTabStrip.setTabIndex(orderStateNumber, true);

    }
    public View getMainView() {
        return mainView;
    }
}
